home *** CD-ROM | disk | FTP | other *** search
- unit MemoTextMainForm;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- Memo1: TMemo;
- Label1: TLabel;
- procedure Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- procedure Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- begin
- { Allow edit -> memo drag & drop }
- Accept := Source is TLabel
- end;
-
- procedure TForm1.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
- var
- Pt: TSmallPoint;
- begin
- with Sender as TMemo do
- begin
- { Turn co-ordinates into a TSmallPoint }
- Pt := PointToSmallPoint(Point(X, Y));
- { Do a down click }
- Perform(wm_LButtonDown, 0, Longint(Pt));
- { Do an up click }
- Perform(wm_LButtonUp, 0, Longint(Pt));
- { The memo's input caret is now nicely poised }
- { Insert the edit's selected text into the memo }
- SelText := (Source as TLabel).Caption
- end
- end;
-
- end.
-